﻿using System.Collections.Generic;
using System.Windows.Controls;
using System.Windows.Media.Media3D;

namespace Wen.UI.NavigationElements
{
	internal abstract class IndicatorLightViewModelBase<T> : LightViewModelBase<T> where T : Light
	{
		protected abstract IEnumerable<LightIndicator> Indicators { get; }

		private readonly Viewport3D _viewport3D;
		protected Viewport3D Viewport3D {
			get { return _viewport3D; }
		}

		internal IndicatorLightViewModelBase(T light, Viewport3D viewport3D)
			: base(light) {
			_viewport3D = viewport3D;
		}

		private bool _isShowed;
		public bool IsShowed {
			get { return _isShowed; }
			set {
				_isShowed = value;
				foreach (LightIndicator lightIndicator in Indicators) {
					lightIndicator.IsVisible = value;
				}
				RefreshIndicatorsPosition();
			}
		}

		protected abstract void RefreshIndicatorsPosition();

		internal override void Cleanup() {
			base.Cleanup();
			foreach (LightIndicator lightIndicator in Indicators) {
				lightIndicator.Remove();
			}
		}
	}
}
